hvm: Fix CR0 handling, which I broke in 15652.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Jul 2007 08:47:11 +0000 (09:47 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Tue, 31 Jul 2007 08:47:11 +0000 (09:47 +0100)
Thanks to Eric Liu for spotting this.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/hvm.h

index e7842f3e1866db44d4f0faa8eefdca81d0d598d1..7b0ad0af396e1243aaa9e9d8d9bd7c2de9aa4679 100644 (file)
@@ -1677,7 +1677,7 @@ static int svm_set_cr0(unsigned long value)
         return 0;
     }
 
-    value &= HVM_CR0_GUEST_RESERVED_BITS;
+    value &= ~HVM_CR0_GUEST_RESERVED_BITS;
 
     /* ET is reserved and should be always be 1. */
     value |= X86_CR0_ET;
index d8f1317c38857778cf342c4bcdd714c6a1542a4b..b2af52a52d3ace34d173ebdae1e07859156009c3 100644 (file)
@@ -2209,7 +2209,7 @@ static int vmx_set_cr0(unsigned long value)
         return 0;
     }
 
-    value &= HVM_CR0_GUEST_RESERVED_BITS;
+    value &= ~HVM_CR0_GUEST_RESERVED_BITS;
 
     /* ET is reserved and should be always be 1. */
     value |= X86_CR0_ET;
index 30884f58a3881cc5634fd61aa9e38fe47820e3cd..1482f4aaa52552b5e2bdd23f94b6d4907cb0b77b 100644 (file)
@@ -301,22 +301,24 @@ static inline int hvm_event_injection_faulted(struct vcpu *v)
 }
 
 /* These reserved bits in lower 32 remain 0 after any load of CR0 */
-#define HVM_CR0_GUEST_RESERVED_BITS \
-    ~(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | \
-      X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | \
-      X86_CR0_WP | X86_CR0_AM | X86_CR0_NW | \
-      X86_CR0_CD | X86_CR0_PG)
+#define HVM_CR0_GUEST_RESERVED_BITS             \
+    (~((unsigned long)                          \
+       (X86_CR0_PE | X86_CR0_MP | X86_CR0_EM |  \
+        X86_CR0_TS | X86_CR0_ET | X86_CR0_NE |  \
+        X86_CR0_WP | X86_CR0_AM | X86_CR0_NW |  \
+        X86_CR0_CD | X86_CR0_PG)))
 
 /* These bits in CR4 are owned by the host. */
 #define HVM_CR4_HOST_MASK (mmu_cr4_features & \
     (X86_CR4_VMXE | X86_CR4_PAE | X86_CR4_MCE))
 
 /* These bits in CR4 cannot be set by the guest. */
-#define HVM_CR4_GUEST_RESERVED_BITS \
-    ~(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \
-      X86_CR4_DE  | X86_CR4_PSE | X86_CR4_PAE | \
-      X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \
-      X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)
+#define HVM_CR4_GUEST_RESERVED_BITS                     \
+    (~((unsigned long)                                  \
+       (X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD |       \
+        X86_CR4_DE  | X86_CR4_PSE | X86_CR4_PAE |       \
+        X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE |       \
+        X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)))
 
 /* These exceptions must always be intercepted. */
 #define HVM_TRAP_MASK (1U << TRAP_machine_check)